package com.swallow.auth.infrastructure.impl.dept;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.swallow.auth.application.bo.dept.DeptQryRetBO;
import com.swallow.auth.application.repository.dept.IDeptAppRepository;
import com.swallow.auth.infrastructure.convert.dept.CvtDeptRepositoryMapper;
import com.swallow.auth.infrastructure.mysql.mapper.DepartmentMapper;
import com.swallow.auth.infrastructure.mysql.po.DepartmentPO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author: yangjie.deng@resico.cn
 * @since: 2024-05-23 15:15:54
 * @version: v1.0.0
 * @describe:
 */
@Service
public class DeptAppRepositoryImpl implements IDeptAppRepository {

    @Resource private DepartmentMapper departmentMapper;

    @Override
    public DeptQryRetBO getDeptByNo(String deptNo) {
        DepartmentPO dept = departmentMapper.selectOne(Wrappers.lambdaQuery(DepartmentPO.class)
                                                               .eq(DepartmentPO::getDeptNo, deptNo)
                                                      );
        return CvtDeptRepositoryMapper.INSTANCE.deptPO2BO(dept);
    }
}
